<?php

namespace App\Http\Controllers\Cruise\Merchant;

use App\Http\Controllers\BaseController;
use App\Http\Middleware\OpenShop\MerchantAppAuth;
use App\Service\Pay\MybankService;
use Illuminate\Http\Request;

class MybankController extends BaseController
{
    public function inputsInfo(Request $request)
    {
        $userId = MerchantAppAuth::$userId;
        $shopId = (int)$request->header('shopId');
        $onlyStatus = (int)$request->get('onlyStatus', 0);

        $data = (new MybankService($userId))->getInput($shopId, $onlyStatus);

        return $this->success($data);
    }

    public function inputsUpdate(Request $request)
    {
        $userId = MerchantAppAuth::$userId;
        $field  = $request->get('field');
        $value  = $request->get('value');

        (new MybankService($userId))->updateInput($field, $value);

        return $this->success();
    }

    public function inputsSubmit(Request $request)
    {
        $userId = MerchantAppAuth::$userId;

        (new MybankService($userId))->submitInput();

        return $this->success();
    }
}
